package com.ecoolex.ying.space.enums;

import com.ecoolex.framework.common.EnumInterface;
import com.ecoolex.framework.common.util.Check;
import com.ecoolex.ying.space.entity.UserGoodsAttachmentDownloadTask;

import static com.ecoolex.ying.space.enums.GoodsAttachmentType.*;
import static com.ecoolex.ying.space.enums.UserGoodsAttachmentDownloadTaskType.Group.GOODS;
import static com.ecoolex.ying.space.enums.UserGoodsAttachmentDownloadTaskType.Group.PROJECT;

/**
 * @see UserGoodsAttachmentDownloadTask
 */
public enum UserGoodsAttachmentDownloadTaskType implements EnumInterface<UserGoodsAttachmentDownloadTaskType, Integer> {
    GOODS_All(GOODS, null,0,"商品所有附件"),
    GOODS_IMAGE(GOODS, IMAGE,1,"商品图片附件"),
    GOODS_MODEL(GOODS, MODEL,2,"商品3D模型附件"),
//    GOODS_VIDEO(GOODS, VIDEO,3,"商品视频附件"),
//    PROJECT_ALL(PROJECT, null,10,"项目所有附件"),
    PROJECT_ALL_GOODS_IMAGE(PROJECT, IMAGE,11,"项目所有商品图片附件"),
//    PROJECT_ALL_GOODS_MODEL(PROJECT, MODEL,12,"项目所有商品3D模型附件"),
//    PROJECT_ALL_GOODS_VIDEO(PROJECT, VIDEO,13,"项目所有商品视频附件");
    ;

    public enum Group {
        /**
         * 商品
         */
        GOODS,
        /**
         * 项目
         */
        PROJECT
    }

    /**
     * 分组
     */
    private Group group;
    /**
     * 商品附件类型
     */
    private GoodsAttachmentType goodsAttachmentType;

    private int real;


    private String describe;

    UserGoodsAttachmentDownloadTaskType(Group group, GoodsAttachmentType goodsAttachmentType, int real, String describe) {
        this.group = group;
        this.goodsAttachmentType = goodsAttachmentType;
        this.real = real;
        this.describe = describe;
    }

    public GoodsAttachmentType getGoodsAttachmentType() {
        return goodsAttachmentType;
    }

    public static UserGoodsAttachmentDownloadTaskType valueOf(Group group, GoodsAttachmentType goodsAttachmentType) {
        for (UserGoodsAttachmentDownloadTaskType type: values()) {
            if (type.group == group && type.goodsAttachmentType == goodsAttachmentType) {
                return type;
            }
        }
        return null;
    }

    @Override
    public Integer real() {
        return real;
    }

    @Override
    public String describe() {
        return describe;
    }

    @Override
    public UserGoodsAttachmentDownloadTaskType realOf(Integer real) {
        if (Check.notNull(real)) {
            for (UserGoodsAttachmentDownloadTaskType v : values()) {
                if (v.real().equals(real)) {
                    return v;
                }
            }
        }
        return null;
    }

    public static UserGoodsAttachmentDownloadTaskType realValueOf(Integer real) {
        if (Check.notNull(real)) {
            for (UserGoodsAttachmentDownloadTaskType v : values()) {
                if (v.real().equals(real)) {
                    return v;
                }
            }
        }
        return null;
    }
}
